﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    mc:Ignorable="d">
    <Style x:Key="ToolTipStyle"
           TargetType="{x:Type ToolTip}">
        <Setter Property="Foreground"
                Value="{DynamicResource DefaultFontBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolTip}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="5" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="5" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="1"
                                BorderThickness="1"
                                BorderBrush="LightGray"
                                Background="White">
                            <ContentPresenter Margin="4,4,4,4" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate TargetType="{x:Type Fluent:ScreenTip}"
                     x:Key="ScreenTipControlTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="5" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="5" />
            </Grid.RowDefinitions>
            <Border Grid.RowSpan="1"
                    BorderThickness="1"
                    BorderBrush="LightGray"
                    Background="White">
                <Grid>
                    <StackPanel x:Name="screenTipPanel">
                        <TextBlock x:Name="title"
                                   TextWrapping="Wrap"
                                   Margin="7,8,7,10"
                                   FontWeight="Bold"
                                   Text="{TemplateBinding Property=Title}" />
                        <Grid x:Name="imageAndTextSection">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Image Margin="7,5,3,7"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Top"
                                   Source="{TemplateBinding Property=Image}"
                                   MaxHeight="48" />
                            <TextBlock Text="{TemplateBinding Property=Text}"
                                       TextWrapping="Wrap"
                                       Margin="8,0,8,6"
                                       Foreground="#FF414141"
                                       Grid.Column="1" />
                        </Grid>
                        <Border x:Name="separator"
                                Height="2"
                                Width="Auto"
                                HorizontalAlignment="Stretch"
                                Visibility="{Binding ElementName=disableReasonSection, Path=Visibility}"
                                Margin="5"
                                Background="LightGray"
                                BorderThickness="0,0,0,1"
                                IsEnabled="{Binding Path=(IsEnabled), RelativeSource={RelativeSource FindAncestor, AncestorType=Control, AncestorLevel=2}}" />
                        <Grid x:Name="disableReasonSection">
                            <Image Width="16"
                                   Height="16"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Top"
                                   Margin="5,0,0,0"
                                   Source="{DynamicResource ScreenTipWarningImage}" />
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <TextBlock x:Name="disableReasonHeader"
                                           x:Uid="disableReasonHeader"
                                           Text="{Binding Source={x:Static Fluent:Ribbon.Localization}, Path=ScreenTipDisableReasonHeader, Mode=OneWay}"
                                           TextWrapping="Wrap"
                                           Margin="28,0,5,2"
                                           Foreground="#FF414141"
                                           HorizontalAlignment="Stretch"
                                           Grid.Row="0"
                                           FontWeight="Bold" />
                                <TextBlock x:Name="disableReasonText"
                                           Text="{TemplateBinding Property=DisableReason}"
                                           TextWrapping="Wrap"
                                           Margin="28,0,5,6"
                                           Foreground="#FF414141"
                                           HorizontalAlignment="Stretch"
                                           Grid.Row="1" />
                                <TextBlock x:Name="helpText"
                                           TextWrapping="Wrap"
                                           Margin="28,0,5,6"
                                           Foreground="#FF414141"
                                           Grid.RowSpan="1"
                                           Grid.Row="2"
                                           HorizontalAlignment="Stretch"
                                           Text="{Binding Text, ElementName=textBlock, Mode=Default}" />
                            </Grid>
                        </Grid>
                        <Border x:Name="separator2"
                                Height="2"
                                Width="Auto"
                                HorizontalAlignment="Stretch"
                                Visibility="{TemplateBinding Property=HelpLabelVisibility}"
                                Margin="5"
                                Background="LightGray"
                                BorderThickness="0,0,0,1" />
                        <Grid x:Name="helpSection"
                              Visibility="{TemplateBinding Property=HelpLabelVisibility}">
                            <Image Width="16"
                                   Height="16"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Top"
                                   Margin="5,0,0,0"
                                   Source="{DynamicResource ScreenTipHelpImage}" />
                            <TextBlock x:Uid="HelpText"
                                       x:Name="textBlock"
                                       Text="{Binding Source={x:Static Fluent:Ribbon.Localization}, Path=ScreenTipF1LabelHeader, Mode=OneWay}"
                                       TextWrapping="Wrap"
                                       Margin="28,0,6,6"
                                       Foreground="#FF414141"
                                       FontWeight="Bold"
                                       HorizontalAlignment="Stretch" />
                            <ContentControl x:Name="helpTopic"
                                            Content="{TemplateBinding Property=HelpTopic}"
                                            Visibility="Collapsed" />
                        </Grid>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled"
                     SourceName="separator"
                     Value="False">
                <Setter Property="Visibility"
                        TargetName="disableReasonSection"
                        Value="Visible" />
            </Trigger>
            <Trigger Property="IsEnabled"
                     SourceName="separator"
                     Value="True">
                <Setter Property="Visibility"
                        TargetName="disableReasonSection"
                        Value="Collapsed" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Content"
                               SourceName="helpTopic"
                               Value="{x:Null}" />
                    <Condition Property="Text"
                               Value=""
                               SourceName="disableReasonText" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility"
                        TargetName="separator"
                        Value="Collapsed" />
            </MultiTrigger>
            <Trigger Property="Text"
                     SourceName="disableReasonText"
                     Value="">
                <Setter Property="Visibility"
                        TargetName="disableReasonSection"
                        Value="Collapsed" />
            </Trigger>
            <Trigger Property="Content"
                     SourceName="helpTopic"
                     Value="{x:Null}">
                <Setter Property="Visibility"
                        TargetName="helpText"
                        Value="Collapsed" />
                <Setter Property="Visibility"
                        TargetName="helpSection"
                        Value="Collapsed" />
                <Setter Property="Visibility"
                        TargetName="separator2"
                        Value="Collapsed" />
            </Trigger>
            <Trigger Property="Visibility"
                     SourceName="disableReasonSection"
                     Value="Visible">
                <Setter Property="Visibility"
                        TargetName="helpText"
                        Value="Collapsed" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Text"
                               Value="" />
                    <Condition Property="Image"
                               Value="{x:Null}" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility"
                        TargetName="imageAndTextSection"
                        Value="Collapsed" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="ScreenTipStyle"
           TargetType="{x:Type Fluent:ScreenTip}">
        <Setter Property="Foreground"
                Value="{DynamicResource DefaultFontBrush}" />
        <Setter Property="Width"
                Value="205" />
        <Setter Property="Template"
                Value="{DynamicResource ScreenTipControlTemplate}" />
    </Style>
</ResourceDictionary>